#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#define maxsize 100
typedef int keytype;
typedef struct
{
	keytype key;
}redtype;
typedef struct
{
	redtype r[maxsize];
	int length;
}sqlist;
void Shell(redtype* arr, int sz)
{
	int gap = sz;

	while (gap > 1)
	{

		gap = gap / 3 + 1;
		for (int i = 0; i < sz - gap; i++)
		{
			redtype tmp = arr[i + gap];
			int end = i;
			while (end >= 0)
			{
				if (tmp.key < arr[end].key) arr[end + gap] = arr[end], end -= gap;
				else break;
			}

			arr[end + gap] = tmp;
		}
	}
}
int main()
{
	int n;
	std::cin >> n;
	sqlist sl;
	sl.length = n;
	for (int i = 0; i < n; i++)
	{
		std :: cin >> sl.r[i].key;
	}
	Shell(sl.r, n);
	return 0;
}